       //===============引入头部 和底部的文=====================
       $("#header").load("aaheader.html");
       $("#bottom").load("aabottom.html");
   
    // ====================点击加减号实现加减========================
   
       //===========将底下小图的路径赋值给上面大图和放大图
       function magnifier(obj1, obj2, obj3,) {
           obj1.click(
               add = $("obj1").attr("src"),
               $("obj2").attr("src", "add"),
               $("obj3").attr("src", "add")
           )
       }
       //===获取上一页传值=== 
       function getgoodsId() {
           return location.search.split("=")[1];
       }
       //===============用ajax调取后端的数据=================
       $(function () {
           $.get(
               "getGoodsInfo.php",
               { "goodsId": getgoodsId() },
               function (data) {
                //    console.log(data);
   
                   $("#lll").html(data.goodsName);
                   $(".price-inner").html(data.goodsPrice);
                   $("#details").html(data.goodsDesc);
                   $("#number").html(data.goodsId);
                   $("#category").html(data.goodsType);
                   // $("#one").html().css({"background-image":""})
   
               }, "json")
                   // 修改数字
       function changeNum(obj, operator) {
           // 1、获取原来的数字和价格
           let num = obj.parentNode.querySelector(".count").value;
   
           // 2、修改数量
           operator == "+" ? num++ : num--;
           num = num < 0 ? 0 : num;
   
           // 3、3、把结果显示在界面上
           // 1）、修改数量
           obj.parentNode.querySelector(".count").value = num;
           // 2）、修改小计
       }
       $("#reduce").click(function () {
           changeNum(this, "-")
   
       });
       $(".add").click(function () {
           changeNum(this, "+")
           
   
       });
            });
   
   
   //=========加入购物车=======================
   $("#goshopp").click(function(){
   if(getCookie("username")==""||getCookie("username")==null){
       location.href="aaRegister.html";
   }else{
       SubmitData();
     
   }
   
   
   })
   
   
   
   
   //向后端添加
   function SubmitData() {
           $.post(
               "addShoppingCart.php",
               {
                   "goodsId": getgoodsId(),
                   "vipName": getCookie("username"),
                   "goodsCount":$("#count").val(),
               },
               function (data) {
                   // console.log(data)
                   location.href="aashoppingcar.html?";
                   
               } , );
     


   
   //====================放大镜====================
       class MagniFy {
           constructor(small, mask, big, lis) {
               this.small = small;
               this.mask = mask;
               this.big = big;
               this.lis = lis;
               this.eventbind();
           }
   
   
           mouseover() {
               let that = this;
               this.small.onmouseover = function () {
                   that.mask.style.display = "block";
                   that.big.style.display = "block";
               }
           }
           mouseout() {
               let that = this;
               this.small.onmouseout = function () {
                   that.mask.style.display = "none";
                   that.big.style.display = "none"
               }
           }
           mousemove() {
               let that = this;
               //1.给小盒子绑定移动事件
               this.small.onmousemove = function (evt) {
                   let e = evt || event;
                   //2`.将鼠标的坐标赋值给遮罩的位置
                   let left = e.pageX - this.offsetLeft - that.mask.offsetWidth / 2;
                   let top = e.pageY - this.offsetTop - that.mask.offsetHeight / 2;
                   //3·对遮罩进行边界的判断
                   if (left < 0) {
                       left = 0;
                   }
                   if (top < 0) {
                       top = 0;
                   }
                   let leftMax = this.offsetWidth - that.mask.offsetWidth;
                   if (left > leftMax) {
                       left = leftMax;
                   }
                   let topMax = this.offsetHeight - that.mask.offsetHeight;
                   if (top > topMax) {
                       top = topMax;
                   }
                   that.mask.style.left = left + "px";
                   that.mask.style.top = top + "px";
   
                   //4·对大背景得方向进行一个改变
                   let x = that.big.offsetWidth * left / that.mask.offsetWidth;
                   let y = that.big.offsetHeight * top / that.mask.offsetHeight;
   
                   that.big.style.backgroundPositionX = -x + "px";
                   that.big.style.backgroundPositionY = -y + "px"
               }
           }
   
   
           //扩展:点击哪一个图片就将哪一个图片进行
           //第一步:遍历<li></li>
           eventbind() {
               this.mouseover();
               this.mouseout();
               this.mousemove();
           }
           //获取盒子
   
       }
   
       let osmallbox = document.querySelector("#cupLeft-smallbox")
       let omask = document.querySelector("#cupLeft-mask")
       let obigbox = document.querySelector("#big-box")
       let olis = document.querySelector("#cupLeft-bottom li");
       let mf = new MagniFy(osmallbox, omask, obigbox, olis);
   
   
   }
$("#me").click(function(){
    $("#pingluntianjia").css({
        "display": "block",
    })
})
//点击提交评论提交到后端
$("#goshopp").click(function(){
 
    
    
    })
$("#tijiao").click(function(){  
    if(getCookie("username") == ""||getCookie("username")==null){
        location.href="aaRegister.html";
    }else{
        $.post(                    
            "addComment.php",   
            {
                "vipName":getCookie("username"),
                "goodsId":getgoodsId(),
                "content":$("#pinglunkuang").val(),
            },
            function (data) {
                console.log(data)
            }, "json");
      
    }
     $("#tijiao").val(" ")
})


// 获取评论区关于这个东西里面的评论 
$(function () {
    $.get(
        "getComment.php",
        { "goodsId":getgoodsId()},
       
        function (data) {
            let htmlr ="";
            data.forEach(element => {

                htmlr +=`
                <li><span id="namesss">${element.vipName}</span>
                :<span id="time">${element.commentTime}</span> <p id="ppppp">${element.content}</p>
            </li>
            `
            $("#pinglunxianshi").html(htmlr)
            console.log(data);
            });
           
           
        },"json")
});